<template>
	<view class="content">
		<image class="logo" src="/static/jslog.jpg"></image>
		<view class="text-area">
			<form>
			<input type='text' class="inputText" v-model="account" placeholder="请输入帐号" >
			<input type='password' class="inputText" v-model="passwd" placeholder="请输入密码" >
			<button class="btn" @click="login()">登 录</button>
			</form>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				account:'',
				passwd:'',
			}
		},
		onLoad() {

		},
		methods: {
			reg(){
				let that = this
				if (!this.account|| this.account == null || this.account==undefined || this.account=='undefined') {
					alert('账号 不能为空');
					return
				}
				
				if (!this.passwd|| this.passwd == null || this.passwd==undefined || this.passwd=='undefined') {
					alert('密码 不能为空');
					return
				}
				uni.request({
				    url: that.$host+'/api/v1/user/login', // 你的API接口地址
				    method: 'POST',
					header:{'content-type':'application/x-www-form-urlencoded;charset=utf-8',},
				    data: {
						phone:this.account,
						passwd:this.passwd,
						},
				    success: (res) => {
						if(res.data.code == 200){
							var user = JSON.stringify({nickname:res.data.data.Nickname,id:res.data.data.Id,token:res.data.data.Token})
							localStorage.setItem('jslogUser', user);
							uni.navigateTo({
							    url: '/pages/chat/list'
							});
						}else{
							alert(res.data.msg)
						}
				    },
				    fail: (err) => {
						alert(err)
				    }
				});
			},
		}
	}
</script>

<style>

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

.inputText{
    min-height: 76rpx;
    border: 1rpx solid #dadbde;
    font-size: 36rpx;
    padding-left: 20rpx;
    border-radius: 8rpx;
    margin-left: 25rpx;
    margin-top: 20rpx;
	width:90%;
	height:76rpx;
}
.btn {
    margin-top: 20rpx;
	width:60%;
	height:69rpx;
	line-height:69rpx;
	justify-content: center;
	background: #3E7BFA;
}
</style>
